package com.qf.qfarticle.controller.v1;

import com.qf.qfarticle.service.ApArticleService;
import com.qf.qfleadnewscommons.mvc.ThreadLocalUtils;
import com.qf.qfleadnewsmodel.article.dtos.ArticleHomePageDto;
import com.qf.qfleadnewsmodel.commons.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Slf4j
public class ArticleController {

    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomePageDto articleHomePageDto){
        Long uid = ThreadLocalUtils.getUid();
        log.info("--------" + uid);

        return apArticleService.load(articleHomePageDto);
    }
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomePageDto articleHomePageDto){

        return apArticleService.loadMoreOrNew(articleHomePageDto);
    }
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomePageDto articleHomePageDto){

        return apArticleService.loadMoreOrNew(articleHomePageDto);
    }
}
